define(['../../../../../js/lib/other/sweet-alert'],function() {
    return ['$scope','$location', '$interval','$timeout','bizProxy', function($scope,$location,$interval,$timeout,bizProxy) {
		$scope.$emit("top-show",'true');//顶部显示
    	$scope.$emit('menuTypeLight','mine'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','6');//显示底部文字
    	
    	$scope.secondPwd = _YHC_util.strToArr("");
    	var tempRandom = 2.3,tempPassword = "";
    	$scope.$emit("pwdSlidUp",2);
    	
    	//监听子集显示顶部显示
        $scope.$on('pwdChange', function(event, data) {
        	$timeout(function(){
        		if(data.length == 6){
        			tempPassword = data;
        		}
        		$scope.secondPwd = _YHC_util.strToArr(data);
        	},0);
        });
    	
    	//点击获取密码数据
    	$scope.getPassword = function(){
    		$scope.$emit("pwdSlidUp",tempRandom++);
    	}
    	
    	//监听第一次密码输入
    	$scope.$watch('secondPwd', function() {
    		if(($scope.secondPwd)[5] != ""){
    			if(tempPassword == transData.pwd1){
    				transData.pwd2 = tempPassword;
    				transData.password = transData.pwd2;
    				$timeout(function(){
    					registerUser();
    				},200);
    			}else{
    				$scope.$emit("promptAlertMsg","密码不一致，请重新输入");
    				$scope.$emit("showCollect",true);
    				$timeout(function(){
    					$scope.$emit("showCollect",false);
    					history.back();
    				},transData.promptTime);
    			}
    		}
		});
    	
    	//调用代理注册
    	function registerUser(){
    		var headerInfo = {},sendData = {};
        	headerInfo.pageNum = '';
        	headerInfo.pageSize = '';
        	headerInfo.sessionId = transData.sessionId;
        	
    		sendData.mobileNo = transData.mobileNo;
    		sendData.mobileCheckNo = transData.mobileCheckNo;
    		sendData.userType = transData.userType;
    		sendData.password = transData.password;
    		sendData.regType = 'app';
    		$scope.$emit("loadingChangeNav",true);
    		bizProxy.queryProxyBizData("userReg",headerInfo,sendData,
    				function(tempData){//SUCCESS
    					$scope.$emit("loadingChangeNav",false);
    					$timeout(function(){
							$scope.$emit("goNext","/regSuccess");
						},0);
		    		},function(data){//FAIL
		    			if(data != ""){
		    				$scope.$emit("loadingChangeNav",false);
		    				if(data.errorCode == ERROR_CODE.checkNo){
								$scope.$emit("promptAlertMsg","验证码输入错误");
								$scope.$emit("showCollect",true);
								$timeout(function(){
									$scope.$emit("showCollect",false);
									transData.pwd1 = "",transData.pwd2 = "",transData.password = "";
		    						$scope.$emit("goNext","/register");
								},transData.promptTime);
							}else{
								$scope.$emit("promptAlertMsg",data.errorMsg);
								$scope.$emit("showCollect",true);
								$timeout(function(){
									$scope.$emit("showCollect",false);
									transData.pwd1 = "",transData.pwd2 = "",transData.password = "",transData.mobileCheckNo = "",transData.mobileNo = "";
		    						$scope.$emit("goNext","/mine");
								},transData.promptTime);
								
							}
		    			}else{
		    				$scope.$emit("loadingChangeNav",false);
		    				$scope.$emit("promptAlertMsg","连接超时");
							$scope.$emit("showCollect",true);
							$timeout(function(){
								$scope.$emit("showCollect",false);
								transData.pwd1 = "",transData.pwd2 = "",transData.password = "",transData.mobileCheckNo = "",transData.mobileNo = "";
	    						$scope.$emit("goNext","/mine");
							},transData.promptTime);
		    			}
		    		});
    	}
    	
    	
    	//当键盘被销毁的时候
        $scope.$on("$destroy", function() {
        	$scope.$emit("pwdSlidUp","");
	    });
        $scope.$apply();
    }];
});